home *** CD-ROM | disk | FTP | other *** search
- class Player extends MovieClipHolder implements Steppable
- {
- var mc;
- var tms;
- static var SPEED_DIAG;
- static var SPEED = 10;
- static var MAXHEALTH = 100;
- var health = Player.MAXHEALTH;
- function Player(x, y)
- {
- super(_root.attachMovie("player","player" + _root.getNextHighestDepth(),_root.getNextHighestDepth()),204);
- this.mc._x = x;
- this.mc._y = y;
- this.mc.blendMode = "normal";
- Player.SPEED_DIAG = Math.sqrt(Player.SPEED * Player.SPEED / 2);
- this.tms = new Array();
- if(_root.effects >= 2)
- {
- this.tms.push(new TrailManager(this.mc,this.mc.exhaust1,5,16566787));
- this.tms.push(new TrailManager(this.mc,this.mc.exhaust2,5,16566787));
- }
- else
- {
- this.tms.push(new TrailManager(this.mc,this.mc.exhaust1,5));
- this.tms.push(new TrailManager(this.mc,this.mc.exhaust2,5));
- }
- Stepper.add(this);
- }
- function step()
- {
- this.move();
- this.checkHit();
- }
- function checkHit()
- {
- var _loc3_ = 0;
- while(_loc3_ < Missile.missiles.getLength())
- {
- var _loc2_ = Missile.missiles["get"](_loc3_);
- if(_loc2_.hit(this.mc,false,true))
- {
- this.health -= _loc2_.getDamage() * 1.75;
- _loc2_.die();
- ScoreManager.resetMultiplier();
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- if(this.health <= 0)
- {
- LevelManager.signalDeath();
- }
- }
- function makeTrail()
- {
- var _loc2_ = 0;
- while(_loc2_ < this.tms.length)
- {
- this.tms[_loc2_].makeTrail();
- _loc2_ = _loc2_ + 1;
- }
- }
- function move()
- {
- var _loc3_ = undefined;
- var _loc2_ = undefined;
- if(Key.isDown(40) || Key.isDown(83))
- {
- if(Key.isDown(37) || Key.isDown(65))
- {
- _loc3_ = this.mc._x - Player.SPEED_DIAG;
- _loc2_ = this.mc._y + Player.SPEED_DIAG;
- this.mc._rotation = 225;
- }
- else if(Key.isDown(39) || Key.isDown(68))
- {
- _loc3_ = this.mc._x + Player.SPEED_DIAG;
- _loc2_ = this.mc._y + Player.SPEED_DIAG;
- this.mc._rotation = 135;
- }
- else
- {
- _loc2_ = this.mc._y + Player.SPEED;
- this.mc._rotation = 180;
- }
- this.makeTrail();
- }
- else if(Key.isDown(38) || Key.isDown(87))
- {
- if(Key.isDown(37) || Key.isDown(65))
- {
- _loc3_ = this.mc._x - Player.SPEED_DIAG;
- _loc2_ = this.mc._y - Player.SPEED_DIAG;
- this.mc._rotation = -45;
- }
- else if(Key.isDown(39) || Key.isDown(68))
- {
- _loc3_ = this.mc._x + Player.SPEED_DIAG;
- _loc2_ = this.mc._y - Player.SPEED_DIAG;
- this.mc._rotation = 45;
- }
- else
- {
- _loc2_ = this.mc._y - Player.SPEED;
- this.mc._rotation = 0;
- }
- this.makeTrail();
- }
- else if(Key.isDown(37) || Key.isDown(65))
- {
- _loc3_ = this.mc._x - Player.SPEED;
- this.mc._rotation = -90;
- this.makeTrail();
- }
- else if(Key.isDown(39) || Key.isDown(68))
- {
- _loc3_ = this.mc._x + Player.SPEED;
- this.mc._rotation = 90;
- this.makeTrail();
- }
- if(_loc3_ < 0)
- {
- _loc3_ = 0;
- }
- else if(_loc3_ > Stage.width)
- {
- _loc3_ = Stage.width;
- }
- if(_loc2_ < 0)
- {
- _loc2_ = 0;
- }
- else if(_loc2_ > Stage.height)
- {
- _loc2_ = Stage.height;
- }
- this.mc._x = _loc3_;
- this.mc._y = _loc2_;
- }
- function getHealth()
- {
- return this.health;
- }
- function renewHealth()
- {
- this.health = Player.MAXHEALTH;
- }
- function die()
- {
- Stepper.remove(this);
- this.mc.removeMovieClip();
- }
- }
-